<!DOCTYPE html>
<html lang="en">
<head>
    <title>检验项目-精工云MES系统移动端</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <link href="/JG/Content/jquery/weui/style/weui.min.css" rel="stylesheet" />
    <link href="/JG/Content/jquery/jquery-weui/css/jquery-weui.min.css" rel="stylesheet" />
    <link rel="stylesheet" href="/JG/Content/css/bootstrap.min.css">
    <link href="/JG/Content/css/Global.css" rel="stylesheet" />
    <link href="/JG/Content/jquery/jquery-weui/css/icon.css" rel="stylesheet" />
    <link rel="stylesheet" href="/JG/Content/css/MobileCheckoutProject.css?v=1">

    <script src="/JG/Content/jquery/jquery-3.2.1.min.js"></script>
    <script src="/JG/Content/LocalConfigs.js"></script>
    <script src="/JG/Content/LocalUserInfo.js"></script>
    <script src="/JG/Content/Utils.js?v=1"></script>
</head>
<body>
    <div id="ContentContainer">
        <!--header部分-->
        <header class="header">
            <div class="empty">
                <span id="stations"></span>
            </div>
            <div class="weui-flex">
                <div class="weui-flex__item" style="position:absolute;">
                <span style="font-size:16px;padding-left: 10px;" class="icon icon-109 f-white" onclick="javascript:location.href='/JG/Quality/MobileFirstItemInspection.html'">
                    返回
                </span>
                </div>
                <div class="weui-flex__item" style="text-align: center;">检验项目</div>
                <div class="weui-flex__item" style="position:absolute;right:10px;">
                    <span><img src="/JG/Content/images/save.png" alt="" style="width:25px;"></span>
                </div>
            </div>
        </header>

        <!--解决浮动空内容div-->
        <div class="empty_div"></div>

        <!--主体部分-->
        <div id="MainPage" v-cloak>
            <div class="tree_form">
                <!--无限层级菜单部分-->
                <!--<div id="menuTree" class="menuTree"></div>-->


                <div class="menuTree">
                    <div class="big_title">
                        <span @click="GetRootID(item,index)" v-for="(item,index) in CheckoutClassifyData">{{item.JCXMFL_FLMC}}</span>
                    </div>
                    <!--树形结构数据-->
                    <div class="all_detail">
                        <div id="detail_list" class="detail_list"></div>
                        <!--<div id="detail_item" class="detail_item"></div>-->
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>

<script src="/JG/Content/jquery/jquery-weui/js/jquery-weui.min.js"></script>
<script src="/JG/Content/bootstrap.min.js"></script>
<script src="/JG/Content/vue-v2.34.js"></script>
<script src="/JG/Content/Common.js"></script>
<script type="text/javascript" src="/JG/Content/TierPullDown.js"></script>

<script type="text/javascript">

    var vmPage = new Vue({
        el:"#ContentContainer",
        data:{
            FormData:{
                MasterID:$.getUrlParam("MasterID"),     //将传过来的检验方案ID转为符合getUrlParam()方法里面的正则
               // RootId:"",     //检验项目分类根目录id
                FirstRootId:"",     //第一个检验项目分类根目录id
                Content:"",
            },
            CheckoutClassifyData:[], //检验项目分类根目录集合（多层级）
            CheckoutProjectData:[],    //检验项目集合（多层级）
            CheckoutItemData:[],      //检测项集合
        },
        mounted:function(){
            var currSelf = this;
            currSelf.TreeFormData();   //初始化
        },

        methods:{
            TreeFormData:function(){
                var currSelf = this;
                if(currSelf.FormData.MasterID){
                    //获取检验项目分类的根目录数据
                    $.showLoading();
                    $.ajax({
                        type: "post",
                        async:false,
                        url: LocalConfig.SrvPath + "/jgmes/jgmesFirstInspectionAction!getInspectionItemRootClassify.action",
                        data: {
                            "userCode": LocalUserInfo.GetUserInfo().UserCode,
                            "mac": LocalUserInfo.GetUserInfo().Mac,
                            "jybzID":currSelf.FormData.MasterID,     //主键ID
                        },
                        dataType: "json",
                        success:function(result){
                            var res = ReturnData(result);
                            console.log(res);
                            if(res.IsSuccess){
                                if(res.Data.length>0){
                                    currSelf.CheckoutClassifyData = res.Data;
                                    currSelf.FormData.FirstRootId = res.Data[0].JGMES_ZLGL_JCXMFL_ID;

                                    if(currSelf.FormData.FirstRootId){
                                        currSelf.InitializeCheckout();    //初始化
                                        //循环点击根目录数据显示不同样式
                                        currSelf.$nextTick(function () {     //$nextTick方法是进行获取数据后，对更新后的hmtl做操作
                                            $(".big_title>span:first-child").addClass("active_span");
                                            $(".big_title>span").each(function (index) {
                                                $(this).on("click", function () {
                                                    $(".big_title>span").eq(index).addClass("active_span").siblings(".big_title>span").removeClass("active_span");
                                                    // $(".detail_list>div").hide();
                                                    // $(".detail_list>div").eq(index).show();
                                                })
                                            })
                                        });
                                    }
                                }else {
                                    var showMsg = "此检验方案没有相关检测分类项!";
                                    $.toptip(showMsg, "warning");
                                }
                            }else {
                                $.toptip(res.message, "error");
                            }
                        },
                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                            $.alert("请求失败" + errorThrown);
                        },
                        complete: function () {
                            //当数据加载完成隐藏加载弹窗
                            $.hideLoading();
                        }
                    });
                }
            },

            //初始化检验分类项和分类项目方法
            InitializeCheckout:function(){
                var currSelf = this;
                currSelf.CheckoutProjectData =[];
                str="";
                //获取检验项目明细接口
                $.showLoading();
                $.ajax({
                    type: "post",
                    async:false,
                    url: LocalConfig.SrvPath + "/jgmes/jgmesFirstInspectionAction!getEffectiveProductStandardChild.action",
                    data: {
                        "userCode": LocalUserInfo.GetUserInfo().UserCode,
                        "mac": LocalUserInfo.GetUserInfo().Mac,
                        "jybzID":currSelf.FormData.MasterID,     //首检主键ID
                        "rootId":currSelf.FormData.FirstRootId,    //检验项目分类ID
                    },
                    dataType: "json",
                    success:function(result){
                        var res = ReturnData(result);
                        console.log(res);
                        if(res.IsSuccess){
                            if(res.Data.length>0){
                                currSelf.CheckoutProjectData=res.Data;
                                //添加无级树
                                // document.getElementById("detail_list").innerHTML = forTree(currSelf.CheckoutProjectData);
                                $("#detail_list").html(forTree(currSelf.CheckoutProjectData));
                                currSelf.FormData.Content= str;
                            }else {
                                var showMsg = "此检测分类项无相关检验项目!";
                                $.toptip(showMsg, "warning");
                            }
                        }else {
                            $.toptip(res.message, "error");
                        }
                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        $.alert("请求失败" + errorThrown);
                    },
                    complete: function () {
                        //当数据加载完成隐藏加载弹窗
                        $.hideLoading();
                    }
                });
            },

            //获取当前点击检验项目分类名称方法
            GetRootID:function(val){
                var currSelf = this;
                currSelf.FormData.FirstRootId = val.JGMES_ZLGL_JCXMFL_ID;
                currSelf.InitializeCheckout();     //调用
            },
        },
    });
</script>
</html>